package com.yzh.luckydraw.domain.activity.repository;

import com.yzh.luckydraw.common.Constants;
import com.yzh.luckydraw.domain.activity.model.aggregates.ActivityInfoLimitPageRich;
import com.yzh.luckydraw.domain.activity.model.req.ActivityInfoLimitPageReq;
import com.yzh.luckydraw.domain.activity.model.req.PartakeReq;
import com.yzh.luckydraw.domain.activity.model.res.StockResult;
import com.yzh.luckydraw.domain.activity.model.vo.*;

import java.util.Date;
import java.util.List;

public interface IActivityRepository {
    /**
     * 添加活动配置
     */
    void addActivity(ActivityVO activityVO);

    /**
     * 添加奖品配置
     *
     * @param awardVO
     */
    void addAward(List<AwardVO> awardVO);

    /**
     * 添加策略配置
     *
     * @param strategyVO
     */
    void addStrategy(StrategyVO strategyVO);

    /**
     * 添加策略明细配置
     *
     * @param strategyDetailList
     */
    void addStrategyDetailList(List<StrategyDetailVO> strategyDetailList);

    /**
     * 变更活动状态
     *
     * @param activeId
     * @param beforeState
     * @param afterState
     * @return
     */
    boolean alterState(Long activeId, Enum<Constants.ActivityState> beforeState, Enum<Constants.ActivityState> afterState);

    /**
     * 查询活动账单信息【库存、状态、日期、个人参与次数】
     *
     * @param req
     * @return
     */
    ActivityBillVO queryActivityBill(PartakeReq req);

    /**
     * 扣减活动库存
     *
     * @param activityId
     * @return
     */
    int subtractionActivityStock(Long activityId);

    /**
     * 扣减活动库存（Redis）
     *
     * @param uId
     * @param activityId
     * @param stockCount
     * @param endTime
     * @return
     */
    StockResult subtractionActivityStockByRedis(String uId, Long activityId, Integer stockCount, Date endTime);

    /**
     * 出现异常情况，通过Redis恢复活动库存
     * @param activityId
     * @param tokenKey
     * @param code
     */
    void recoverActivityCacheStockByRedis(Long activityId, String tokenKey, String code);

    /**
     * 扫描待处理的活动列表
     *
     * @param id
     * @return
     */
    List<ActivityVO> scanToDoActivityList(Long id);

    /**
     * 查询活动信息（分页）
     * @param req
     * @return
     */
    ActivityInfoLimitPageRich queryActivityInfoLimitPage(ActivityInfoLimitPageReq req);
}
